/*
 * @Author: zxh
 * @Email: 1271027008@qq.com
 * @Date: 2020-03-10 10:40:30
 * @Descripttion: 
 */
import { Component, OnInit } from '@angular/core';
import { ExamineApproveWareService } from '../examine-approve-ware.service'
import { Router, ActivatedRoute } from '@angular/router';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';

@Component({
  selector: 'app-approval-in',
  templateUrl: './approval-in.component.html',
  styleUrls: ['./approval-in.component.scss']
})
export class ApprovalInComponent implements OnInit {

  constructor(
    private ExamineApproveWareService:ExamineApproveWareService,
    private ActivatedRoute:ActivatedRoute,
    private Router:Router,
    private modal:NzModalService
  ) { }

  ngOnInit() {
    let infoId = this.reqId = this.ActivatedRoute.snapshot.paramMap.get('id');
    this.GetModel(infoId)
  }
  viewModel = {};
  reqId:string = ''
  GetModel(id) {
    let data = {
      id: id
    }
    this.ExamineApproveWareService.getDetail(data).subscribe(res => {
      this.viewModel = res;
    });
  }
  remarks:string = ''
  subApproval(type?){
    let _status = true
    let _title = '确定同意吗？'
    if(type == 2){
      _status = false
      _title = '确定退回吗？'
    }
    let _data = {
      opinion:this.remarks,
      reqId:this.reqId,
      status:_status
    }
    console.log(_data);
    this.modal.confirm({
      nzTitle:_title,
      nzOnOk:()=>{
        this.ExamineApproveWareService.approveAgree(_data).subscribe(res=>{
          console.log(res)
          history.go(-1);
        })
      }
    })
  }
  Return() {
    history.go(-1);
  }
}
